package designmode.Observer.v2;

/**
 * Created by Administrator on 2017/10/30 030.
 */
public class OLEDDisplay implements Observer, DisplayDevice
{
    private Observable weather;

    public OLEDDisplay(Observable weather)
    {
        this.weather = weather;
        weather.addObserver(this);
    }

    private float pressure;

    @Override
    public void display()
    {
        System.out.println("Oled更新数据:" + pressure + "MPa");
    }

    @Override
    public void update(Observable able, Object obj)
    {
        if(able instanceof WeatherData)
        {
            WeatherData wd = (WeatherData) able;
            pressure = wd.getPressure();
            display();
        }
    }
}
